package com.renhuikeji.taobaoweb;

import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.webkit.JsResult;
import android.webkit.WebChromeClient;
import android.webkit.WebView;

/**
 * Created by Administrator on 2017/8/31.
 */

public class MywebChromeClient  extends WebChromeClient {
    private Context context;

    public MywebChromeClient(Context context) {
        this.context = context;
    }

    @Override
    public boolean onJsAlert(WebView view, String url, String message, final JsResult result) {
// 弹窗处理
        AlertDialog.Builder b2 = new AlertDialog.Builder(context)
                .setTitle(R.string.app_name).setMessage(message)
                .setPositiveButton("ok", new AlertDialog.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        result.confirm();
                    }
                });
        b2.setCancelable(false);
        b2.create();
        b2.show();
        return true;
    }
}
